#pragma once

#include "EggApp.h"

class HelloWorld:public EggApp{
protected:

    void onRendering(){
        //mTeapotTransform->rotate(1.0f,vec3(0,1,0),TS_LOCAL);
    }

    void setupCamera(){
        EggApp::setupCamera();
        Image2D posx("media/posx.jpg",ILO_FLIPY);
        Image2D negx("media/negx.jpg",ILO_FLIPY);
        Image2D posy("media/posy.jpg",ILO_FLIPY);
        Image2D negy("media/negy.jpg",ILO_FLIPY);
        Image2D posz("media/posz.jpg",ILO_FLIPY);
        Image2D negz("media/negz.jpg",ILO_FLIPY);
        TextureCubePtr snow(new TextureCube(posx,negx,posy,negy,posz,negz));
        //mCamera->setSkyBox(snow);
    }

    void setupLights(){
        //PointLight* p1=new PointLight();
        //PointLight* p2=new PointLight();
        //Transform* t1=new Transform();
        //Transform* t2=new Transform();
        //SceneNode* n1=new SceneNode();
        //SceneNode* n2=new SceneNode();
        //p1->addTo(n1);
        //t1->addTo(n1);
        //t1->setPosition(vec3(0,50,50));
        //p2->addTo(n2);
        //t2->addTo(n2);
        //t2->setPosition(vec3(0,-50,0));
        //mRootNode->addChild(n1);
        //mRootNode->addChild(n2);
    }

    void setupDisplay(){
        setupMaterial();
        mMeshTransform=new TransformActor();
        mMeshTransform->addTo(mScene->getRoot());
        mMesh=new MeshActor();
        mMesh->load("media/teapot.obj");
        mMesh->addTo(mMeshTransform);
        mMesh->setMaterial(mMaterials[0]);
    }

    void setupMaterial(){
        GPUProgramPtr simple(new GPUProgram());
        ShaderPtr vs(new Shader(ST_Vertex));
        ShaderPtr fs(new Shader(ST_Fragment));
        vs->load("glsl/simple_forward.vs");
        fs->load("glsl/simple_forward.fs");
        simple->addShader(vs);
        simple->addShader(fs);
        MaterialPtr mtl(new Material());
        FlatPass* pass0=new FlatPass();
        pass0->addTo(mtl);
        pass0->setParam("color",vec4(1,0,0,1));
        mMaterials.push_back(mtl);
    }
protected:
    MeshActor* mMesh;
    TransformActor* mMeshTransform;
    vector<MaterialPtr> mMaterials;
};